﻿using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.Contracts.Interface.Iridgepletype;
using IntelligentAgriculture.Services.Ridegp_eService;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.RidgepCpoamd;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ManageCommandHandler
{
    public class ManagerDeleteCommandHandler : IRequestHandler<ManagerDeleteCommand, Results<int>>
    {
        private readonly IManageService _manageService;

        public ManagerDeleteCommandHandler(IManageService manageService)
        {
            _manageService = manageService;
        }

        /// <summary>
        /// 删除耳标命令的请求
        /// </summary>
        /// <param name="request">要处理的耳标删除命令</param>
        /// <param name="cancellationToken">取消操作的取消标记</param>
        /// <returns>一个表示操作结果的异步任务，返回删除操作的结果</returns>
        public async Task<Results<int>> Handle(ManagerDeleteCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _manageService.Delete(request.Id);
                return Results<int>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
